{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 偏最小二乘回归分析\n",
    "[参考网站](https://www.cnblogs.com/duye/p/9031511.html）\n",
    "- 当数据量小，甚至比变量维数还小，而相关性又比较大时使用，这个方法甚至优于主成分回归。  \n",
    "\n",
    "[sklearn.cross_decomposition.PLSRegression文档](https://scikit-learn.org/stable/modules/generated/sklearn.cross_decomposition.PLSRegression.html)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[ 0.26087869  0.15302213]\n",
      " [ 0.60667302  0.45634164]\n",
      " [ 6.46856199  6.48931562]\n",
      " [11.7638863  12.00132061]]\n"
     ]
    }
   ],
   "source": [
    "from sklearn.cross_decomposition import PLSRegression\n",
    "X = [[0., 0., 1.], [1.,0.,0.], [2.,2.,2.], [2.,5.,4.]]\n",
    "Y = [[0.1, -0.2], [0.9, 1.1], [6.2, 5.9], [11.9, 12.3]]\n",
    "pls2 = PLSRegression(n_components=2)\n",
    "pls2.fit(X, Y)\n",
    "Y_pred = pls2.predict(X)\n",
    "print(Y_pred)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
